Package com.aptana.js.interactive_console.rhino

Source Code of com.aptana.js.interactive_console.rhino.RhinoConsoleMainTest

package com.aptana.js.interactive_console.rhino;

import java.io.IOException;

import junit.framework.TestCase;

import org.eclipse.core.runtime.NullProgressMonitor;

import com.aptana.interactive_console.console.InterpreterResponse;
import com.aptana.js.interactive_console.console.JSConsoleCommunication;
import com.aptana.js.interactive_console.console.env.RhinoEclipseProcess;
import com.aptana.shared_core.callbacks.ICallback;
import com.aptana.shared_core.log.Log;
import com.aptana.shared_core.net.SocketUtil;
import com.aptana.shared_core.structure.Tuple;

public class RhinoConsoleMainTest extends TestCase {

    public void testRhinoConsole() throws Exception {
        final RhinoConsoleMain console = new RhinoConsoleMain();
        final Integer[] unusedPorts = SocketUtil.findUnusedLocalPorts(2);
        new Thread() {
            public void run() {
                try {
                    console.startXmlRpcServer(unusedPorts[0]);
                } catch (IOException e) {
                    Log.log(e);
                }
            };
        }.start();
        RhinoEclipseProcess process = new RhinoEclipseProcess(0, 0);
        JSConsoleCommunication comm = new JSConsoleCommunication(unusedPorts[0], process, unusedPorts[1]);
        ICallback<Object, Tuple<String, String>> onContentsReceived = new ICallback<Object, Tuple<String, String>>() {

            public Object call(Tuple<String, String> arg) {
                return null;
            }
        };
        ICallback<Object, InterpreterResponse> onResponseReceived = new ICallback<Object, InterpreterResponse>() {

            public Object call(InterpreterResponse arg) {
                return null;
            }
        };
        comm.hello(new NullProgressMonitor());
        comm.execInterpreter("var a = 10;", onResponseReceived, onContentsReceived);
        comm.getCompletions("var a = 10;", "a", 5);
        comm.getDescription("a");
        comm.close();

    }
}
TOP

Related Classes of com.aptana.js.interactive_console.rhino.RhinoConsoleMainTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.